#ifndef MLINE_H
#define MLINE_H

#include "mconfig.h"
#ifdef GUI_APPLICATION

#include "geometry/mpoint.h"

class MLinePrivate;

class MLine
{
	public:
		inline MLine() {}

		MLine(int x0, int y0, int x1, int y1) :
			p0(x0, y0), p1(x1, y1) {}

		MLine(const MPoint &point0, const MPoint &point1) :
			p0(point0), p1(point1) {}

		MLine(const MLine &other) :
			p0(other.p0), p1(other.p1) {}

	public:
		inline const MPoint &point1() const { return p0; }
		inline const MPoint &point2() const { return p1; }
		inline int length() const { return p0.distanceFrom(p1); }
		inline bool isNull() const { return p0 == p1; }

	public:
		inline void setPoint1(int x, int y) { p0.move(x, y); }
		inline void setPoint1(const MPoint &point) { p0.move(point); }

		inline void setPoint2(int x, int y) { p1.move(x, y); }
		inline void setPoint2(const MPoint &point) { p1.move(point); }

		void setLine(int x0, int y0, int x1, int y1);
		void setLine(const MPoint &point0, const MPoint &point1);
		void setLine(const MLine &other);

	public:
		bool isOnLine(const MPoint &point) const;
		bool isOnLine(int x, int y) const;

	public:
		const MLine &operator=(const MLine &other);
		bool operator&(const MLine &other) const;

		inline bool operator==(const MLine &other) const
		{ return p0 == other.p0 and p1 == other.p1; }

		inline bool operator!=(const MLine &other) const
		{ return p0 != other.p0 or p1 != other.p1; }

	private:
		MPoint p0;
		MPoint p1;
};


#endif //GUI_APPLICATION

#endif //MLINE_H
